{% extends 'base.html' %}
{% load blog_tags %}
{% block main %}
<article class="post post-{{ post.pk }}">
  <header class="entry-header">
    <h1 class="entry-title">{{ post.title }}</h1>
    <div class="entry-meta">
      <span class="post-category"><a href="#">{{ post.category.name }}</a></span>
      <span class="post-date"><a href="#"><time class="entry-date"
                                                datetime="{{ post.created_time }}">{{ post.created_time }}</time></a></span>
      <span class="post-author"><a href="#">{{ post.author }}{{ post.user.name }}</a></span>
      <span class="comments-link"><a href="#">{{ post.comment_set.count }} 评论</a></span>
      <span class="views-count"><a href="#">{{ post.views }} 阅读</a></span>
    </div>
  </header>
  <div class="entry-content clearfix">
      {% autoescape off %}
    {{ post.body|safe }}
     {% endautoescape %}
  </div>
</article>

<section class="comment-area">
<h3>发表评论</h3>

<form action="{% url 'comments:post_comment' post.pk %}" method="post" class="comment-form">
{% csrf_token %}
  <div class="row">
    <div class="col-md-4">
      <label for="{{ form.name.id_for_label }}">名字：</label>
          {{ form.name }}
          {{ form.name.errors }}
    </div>
    <div class="col-md-4">
      <label for="{{ form.email.id_for_label }}">邮箱：</label>
          {{ form.email }}
          {{ form.email.errors }}
    </div>
    <div class="col-md-4">
      <label for="{{ form.url.id_for_label }}">URL：</label>
          {{ form.url }}
          {{ form.url.errors }}
    </div>
    <div class="col-md-12">
      <label for="{{ form.text.id_for_label }}">评论：</label>
          {{ form.text }}
          {{ form.text.errors }}
      <button type="submit" class="comment-btn">发表</button>
    </div>
  </div>    <!-- row -->
</form>

<ul class="comment-list list-unstyled">
  {% for comment in comment_list %}
  <li class="comment-item">
    <span class="nickname">{{ comment.name }}</span>
    <time class="submit-date">{{ comment.created_time }}</time>
    <div class="text">
      {{ comment.text }}
    </div>
  </li>
  {% empty %}
  暂无评论
  {% endfor %}
</ul>
</section>
{% endblock main %}

{% block toc %}
    <div class="widget widget-content">
        <h3 class="widget-title">编程语言</h3>
        <ul>
            <li>
                <a href="/">Python</a>
            </li>
            <li>
                <a href="/">PHP</a>
            </li>
            <li>
                <a href="/">Java</a>
            </li>
            <li>
                <a href="/">JavaScript</a>
            </li>
        </ul>
    </div>
    <div class="widget widget-tag-cloud">
               <h3 class="widget-title">标签云</h3>
                    {% get_tags as tag_list %}
                  <ul>
                    {% for tag in tag_list %}
                    <li>
                      <a href="{% url 'blog:category' tag.pk %}">{{ tag.name }}</a>
                    </li>
                    {% empty %}
                    暂无标签！
                    {% endfor %}
                  </ul>
    </div>
    <div class="rss">
    <a href="{% url 'rss' %}"><span class="ion-social-rss-outline"></span> RSS 订阅</a>
    </div>

{% endblock toc %}